{{extend "group_layout.html"}}

{{block group_menu}}
{{include "group_menu.html"}}
{{group_menu(group.name, current="document")}}
{{end}}


{{block group_nav}}
<div class="nav">
    <a href="/group/{{=group.name}}">{{=group.caption}}</a> /
    <a href="/group/{{=group.name}}/document">Document</a> /
    <a href="/group/{{=group.name}}/document/category/{{=doc.category.id}}">{{=doc.category.name}}</a> 
</div>
{{end}}

{{block group_content}}
{{
import os
from uliweb.contrib.upload import get_url
from uliweb.utils.files import str_filesize
}}
<h2>{{=os.path.basename(doc.filename)}}</h2>
<hr></hr>
{{if doc.description.strip():}}
    <p>
    {{=doc.description}}
    </p>
{{else:}}
    <p style="color:gray;font-size:24px">There is no description.</p>
{{pass}}
{{end}}

{{block group_sidebar}}
<div class="box">
    <a href="{{=get_url(doc.filename)}}">Download</a>
    <a href="{{=get_url(doc.filename)}}?action=inline">View</a>
    {{if has_role('group_member', request.user, group_name=group.name):}}
    <a href="/group/{{=group.name}}/document/{{=doc.id}}/edit">Edit</a>
    <a href="/group/{{=group.name}}/document/{{=doc.id}}/delete">Delete</a>
    {{pass}}
</div>
<div class="box">
    <h2>About</h2>
    <div class="box-body">
        <ul class="common-list">
            <li><span>Created at:</span> <strong>{{=doc.create_time.strftime("%Y-%m-%d")}}</strong></li>
            <li><span>Filesize:</span> <strong>{{=str_filesize(doc.size)}}</strong></li>
            <li><span>Uploaded by:</span> <strong>{{=doc.owner.username}}</strong></li>
        </ul>
    </div>
</div>
{{end}}
